#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

/**
 * 测试链接：https://www.luogu.com.cn/problem/B4261
 * 
 */
int main() {
	int x;
	scanf("%d", &x);
	
	for (int y=1; y <= 2025; y++) {
		int result = (x & y) + (x | y);
		if (result == 2025) {
			printf("%d\n",y);
			return 0;
		}
	}

	printf("-1\n");	

	return 0;
}
